//
//  ZGLLoginVC.m
//  Faker
//
//  Created by dllo on 15/11/10.
//  Copyright © 2015年 dllo. All rights reserved.
//

#import "ZGLLoginVC.h"
#import "ZGLLoginDLView.h"
#import "ZGLLoginZCView.h"
#import "ZGLLoginCZView.h"
@interface ZGLLoginVC ()
@property(nonatomic, retain)ZGLLoginDLView *dlview;
@property(nonatomic, retain)ZGLLoginZCView *zcview;
@property(nonatomic, retain)ZGLLoginCZView *czview;
@property(nonatomic, retain)UIView *subview;
@end

@implementation ZGLLoginVC

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor whiteColor];
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"zaihufanhui"] style:(UIBarButtonItemStyleDone) target:self action:@selector(leftBarButtonItem:)];
    self.navigationItem.leftBarButtonItem.tintColor = [UIColor whiteColor];
    
    UISegmentedControl *segment = [[UISegmentedControl alloc]initWithItems:@[@"登录", @"注册", @"重置密码"]];
    segment.frame = CGRectMake(37*ScaleX, 100*ScaleX, 300*ScaleX, 40*ScaleX);
    segment.tintColor = [UIColor grayColor];
    segment.selectedSegmentIndex = 0;
    [segment addTarget:self action:@selector(choose:) forControlEvents:UIControlEventValueChanged];
    [self.view addSubview:segment];
    
    _dlview = [[ZGLLoginDLView alloc]initWithFrame:CGRectMake(37*ScaleX, 138*ScaleX, 300*ScaleX, 240*ScaleX)];
    _zcview = [[ZGLLoginZCView alloc]initWithFrame:CGRectMake(37*ScaleX, 138*ScaleX, 300*ScaleX, 240*ScaleX)];
    _czview = [[ZGLLoginCZView alloc]initWithFrame:CGRectMake(37*ScaleX, 138*ScaleX, 300*ScaleX, 240*ScaleX)];
    
    _subview = _dlview;
    [self.view addSubview:_subview];
}

- (void)leftBarButtonItem:(UIBarButtonItem *)button {
    [self.navigationController popViewControllerAnimated:YES];
}

- (void)choose:(UISegmentedControl *)segment{
    switch (segment.selectedSegmentIndex) {
        case 0:
            [_subview removeFromSuperview];
            _subview = _dlview;
            [self.view addSubview:_subview];
            break;
            
        case 1:
            [_subview removeFromSuperview];
            _subview = _zcview;
            [self.view addSubview:_subview];
            break;
            
        case 2:
            [_subview removeFromSuperview];
            _subview = _czview;
            [self.view addSubview:_subview];
            break;
    }
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
